<?php
/*
Plugin Name: FancyBox
Version: 1.0
Author: _et aka NeBox
Author URI: http://www.templatica.ru/
*/

if (is_page('product_info')) 
{
	add_filter('products_image_block', 'products_image_block_fancybox');
	add_filter('products_mo_image_block', 'products_mo_image_block_fancybox');
	add_filter('head_array_detail', 'head_array_detail_fancybox_head');
}

function products_image_block_fancybox($_value) {
	global $image_pop;
	global $product;
	global $image;
	
    if ( !empty($image_pop) )
    {
	  $_value = '<a href="'.$image_pop.'" title="'.$product->data['products_name'].'" target="_blank" rel="example_group"><img src="'.$image.'"  alt="'.$product->data['products_name'].'" /></a>';
    }
    
	return $_value;
}

function head_array_detail_fancybox_head($_value) { 
	add_js( plugurl().'jquery.fancybox-1.3.1.pack.js', $_value,  'thickbox');
	add_js( plugurl().'fancybox-s.js', $_value,  'thickbox');

	add_style( plugurl().'jquery.fancybox-1.3.1.css', $_value, 'thickbox');

	remove_head_group('fancybox', $_value);

	return $_value;
}


function products_mo_image_block_fancybox($_value) {
	global $product; 

	$_value['PRODUCTS_MO_IMAGE_BLOCK'] =  '<a href="'.$_value['PRODUCTS_MO_POPUP_IMAGE'].'" title="'.$product->data['products_name'].'" target="_blank" rel="example_group"><img src="'.$_value['PRODUCTS_MO_IMAGE'].'"  alt="'.$product->data['products_name'].'" /></a>';

	return $_value;
}
?>